/**
 * Created by Administrator on 2018/8/28.
 */
var afrColumnsHead = [{
    id: 'trCode',
    title: '报销单号',
    width: 250,
    type: 'string',
    columnClass: 'text-center',
}, {
    id: 'afrType',
    title: '报销类别',
    width: 100,
    type: 'string',
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
        if (record.expenseType == "cashType") {
            return "现金报销";
        }else if(record.expenseType == "reception"){
            return "招待报销";
        }
        return "出差报销";
    }
}, {
    id: 'tmpInvoiceNumber',
    title: '发票总数目',
    type: 'string',
    width: 100,
    columnClass: 'text-center',
}, {
    id: 'totalAmount',
    title: '报销总金额',
    type: 'string',
    width: 150,
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
        var content = '￥' + value + '元';
        return content;
      }
}, {
    id: 'temMsg',
    title: '状态',
    type: 'string',
    columnClass: 'text-left',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
       if(value){
           return value;
       }
       return "完成";
    }
}, {
    id: 'applyManName',
    title: '申请人',
    type: 'string',
    width: 80,
    columnClass: 'text-center',
}, {
    id: 'afrTime',
    title: '申请时间',
    type: 'string',
    width: 150,
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
        var date = new Date(record.createTime);
        var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy/MM/dd hh:mm");
        return content;
    }
}, {
    id: 'operation',
    title: '操作',
    width: 60,
    type: 'string',
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
        var content = '';
        if(record.expenseType == "reception"){
            content += '<button class="btn btn-xs btn-primary" onclick="toReception(\'' + record.trCode + '\');"><i class="icon-eye-open"></i>  查看</button>';
            return content;
        }
        content += '<button class="btn btn-xs btn-primary" onclick="toDoCCBX(\'' + record.trCode + '\');"><i class="icon-eye-open"></i>  查看</button>';
        return content;
    }
}];
// var afrGrid = $.fn.dlshouwen.grid.init(afrOption);
//angular 初始化 方法
function bxpage($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams) {
    //打开出差报销申请页面
    $scope.openCCsqView = function () {
        window.location.href = "#/addCCbxLc";
    }

    //打开现金报销申请页面
    $scope.openCashView = function () {
        window.location.href = "#/openCashView";
    }

    $scope.selectTypeSelect = [
        {name:"招待报销",code:"reception"},
        {name:"现金以及出差",code:"main"}
    ]

    $scope.selectChange = function(){

        dataInit.parameters = {
            type:$scope.selectType
        }
        dataInit.refresh(true);
    }
    //展示datagrid 内容
    var dataInit = CertusJsonAjax.dataInit("listccbxDatagrid", {type:"main"}, afrColumnsHead, 'afrContainerDatagrid', 'afrToolBarContainerDatagrid');
    $scope.selectType = "main";
}






//跳转 查看页面
function toDoCCBX(trCode) {
    window.location.href = "#/ccbxInfoDetail/" + trCode;
}

function toReception(trCode){
    window.location.href = "#/toReceptionView/" + trCode;
}